﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Entities.Modules;

namespace MySilverlightApplication.Web
{
    public partial class View : PortalModuleBase
    {
        public string SilverlightApplication { get; set; }
        public string SilverlightInitParams { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            bool isChecked;
            var xapFile = "MySilverlightApplication.xap";
            if (bool.TryParse(Settings["IsTest"].ToString(), out isChecked))
            {
                if (isChecked)
                    xapFile = "MySilverlightApplication.SLTest.xap";
            }
            // Register Silverlight.js file            
            Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "SilverlightJS", (String.Format(@"{0}{1}", TemplateSourceDirectory, "/Silverlight.js")));
            // Set the path to the .xap file   
            SilverlightApplication = String.Format("{0}/ClientBin/{1}", TemplateSourceDirectory, xapFile);
            // Pass the Initialization Parameters to the Silverlight Control            
            SilverlightInitParams = string.Format("Test={0}", "Some init stuff");
        }
    }
}